This invention relates to compiler optimization and, more particularly, to apparatus and methods for eliminating redundant operations establishing common properties using shared real registers.
Compiler optimization is the process of adjusting the output of a compiler to minimize or maximize some attribute of a computer program. A compiler, for example, may be optimized to minimize the execution time of a computer program, minimize the amount of memory used by a computer program, or minimize the amount of power consumed by a computer program as it executes on a machine. Decisions about which optimizations can and should be performed on program code may be tailored to the features and characteristics of a particular machine. The scope of optimizations may vary and may affect anything from a single statement to an entire program.
When compiling program code, the compiler is typically responsible for assigning the relatively large number of program variables (i.e., “virtual registers”) to a smaller number of real registers in a CPU or other processor. This process is often referred to as “register allocation.” Since accessing operands in real registers is significantly faster than accessing operands in memory, the compiler may be configured to keep as many operands as possible in real registers. This will minimize the number of times the computer program has to fetch operands from memory, thereby reducing the execution time of the computer program. Unfortunately, conventional compilers may not take advantage of various optimizations that may be possible when allocating variables to real registers. In particular, conventional compilers may not take advantage of optimizations that are possible when variables share common properties, such as common sets of bits.